Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Barbacan 29 posts 79 karma points
    Jul 16, 2014 @ 16:22
    Barbacan
    0

    CS1513: Expected } ...but where?

    Hi, I'm tring to cycle the images inside a mediafolder called "coverImages". This is my razor code:

    @using umbraco.cms.businesslogic.media;
    @using uComponents.Core;

    @{
        Media startMedia = new Media(1340);   
        foreach(Media m in startMedia.GetChildMedia())
        {
            string umbracoImageFileName = @m.getProperty("umbracoFile").Value.ToString();
            string umbracoImageExtension = @m.getProperty("umbracoExtension").Value.ToString();       
            string imageUrl = CropUp.GetUrl(umbracoImageFileName, new ImageSizeArguments() { CropAlias = "CoverPage" });
            <img src="@imageUrl" />
        }     
    }

    When I save, I got an error "CS1513: Expected }". Seems that the error comes from the row where I define the ImageUrl. Another question, as you can see I get the Media object by Id; can I do by name? in my case carouselImages?

  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    Jul 16, 2014 @ 17:29
    Dennis Aaen
    100

    Hi Barbacan,

    What version of Umbraco are you using and, Which type of file razor did you use for this. Here I am think if you´re using Partial View, or Partial View Maco file. Because the only way I can reproduce the same error as you are using the old legacy Dynamic Node Razor file, (The files that are located under the scripting folder in the developer section) and the dynamic node razor is deprecated.

    If I try to paste the same piece into a parital view or a partial view macro I can save it without any errors.

    The code that you have posted above is strongly typed razor, and for this you need to use a parital view or a partial view macro.

    You can find cheatsheets for Dynamic razor and strongly typed razor here: http://our.umbraco.org/projects/developer-tools/umbraco-v6-mvc-razor-cheatsheets

    Hope this helps,

    /Dennis

Please Sign in or register to post replies

Write your reply to:

Draft